<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单管理-车速递</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/mymain.mymain.css">
    <script type="application/javascript" src="../js/jquery-3.3.1.js"></script>
    <script type="application/javascript" src="../js/bootstrap.min.js"></script>
    <script type="application/javascript" src="../layui/layui.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="../js/vue.min.js"></script>
</head>
<body style="position: static">

<div id="app" class="bgGray">
    <div data-v-95ac8d30="" class="header3">
        <div data-v-95ac8d30="" class="layout clear">
            <div data-v-95ac8d30="" class="left logo">
                <a data-v-95ac8d30="" href="/">
                    <img data-v-95ac8d30=""
                         src="">
                </a>
            </div>
            <div data-v-95ac8d30="" class="header3Nav right">|<a data-v-95ac8d30="" href="/mymain/mymain.html">我的订单</a>|<a
                    data-v-95ac8d30="" href="helpCenter.html">帮助中心</a>|<a data-v-95ac8d30="" href="/pagehome/login.html"
                                                                          onclick="localStorage.clear()">退出</a>
            </div>
            <div data-v-95ac8d30="" class="header3User right">
                <i data-v-95ac8d30="" class="iconfont icon-phone"></i>
                <span data-v-95ac8d30="" class="sp1">400-919-8000</span>
                <span data-v-95ac8d30="" class="sp2">欢迎您，{{ user.tel }}</span>
                <span data-v-95ac8d30="" class="sp3"></span>
            </div>
        </div>
    </div>
    <div class="userInfo">
        <div class="layout">
            <div class="userInfoCom clear">
                <div class="userInfoL left">
                    <div data-v-1cae2c34="" class="userNav">
                        <dl data-v-1cae2c34="" class="userMsg">
                            <dt data-v-1cae2c34="">
                                <img data-v-1cae2c34=""
                                     src="">
                            </dt>
                            <dd data-v-1cae2c34="">
                                <p data-v-1cae2c34=""></p>
                                <p data-v-1cae2c34="" class="p5 pp" style="">普卡会员</p>
                            </dd>
                        </dl>
                        <ul data-v-1cae2c34="" class="manNav">
                            <li data-v-1cae2c34="">
                                <a data-v-1cae2c34="" href="mymain.html" class="">订单管理</a>
                            </li>
                            <li data-v-1cae2c34="">
                                <a data-v-1cae2c34="" href="myinfo.html" class="sel">个人信息</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="userInfoR right">

                    <div class="orderManage manage">
                        <div class="orderManageTit manageTit clear">
                            <div class="left tit">个人信息</div>
                        </div>
                        <div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;">
                            <div class="orderList list">
                                <table class="tableinfo">
                                    <tr>
                                        <td>手机号：{{ user.tel }}</td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td>邮箱：{{ user.email }}</td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <button type="button" class="btn btn-info" @click="edit(user)" >修改</button>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div data-v-3aaf9db2="" class="footer2">
        <div data-v-3aaf9db2="" class="layout clear">
            <div data-v-3aaf9db2="" class="d1">
                <a data-v-3aaf9db2="" href="about.html">关于车速递</a></div>
        </div>
    </div>

    <div class="modal fade" id="editUser">
        <div class="modal-dialog" >
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">X</button>
                    <h4 class="modal-title">用户信息修改：</h4>
                </div>
                <div class ="modal-body" >
                    <div class="input-group">
                        <span class="input-group-addon">TEL:</span>
                        <input class="input-sm" type="text" id="tel" placeholder="1" v-model="user.tel"/>
                    </div>
                    <br/>
                    <div class="input-group">
                        <span class="input-group-addon">EMAIL:</span>
                        <input class="input-sm" type="text" id="email" placeholder="1" v-model="user.email"/>
                    </div>
                </div>
                <div class = "modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss ="modal">取消</button>
                    <button type="button" class="btn btn-primary" @click="confirmEdit">修改</button>
                </div>
            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    var vm = new Vue({
        el: '#app',
        data: {
            user: {
                tel: "",
                email: ""
            }
        },
        methods: {
            edit(user) {
                console.log("user：" + JSON.stringify(user));
                $("#editUser").modal("show");
            },

            confirmEdit() {
                console.log("editUser：" + JSON.stringify(this.user));
                $.ajax({
                    type: "post",
                    url: "/updateUser",
                    data: {
                        id: this.user.id,
                        tel: this.user.tel,
                        email: this.user.email
                    },
                    dataType: "json",
                    success: function (data) {
                        alert("修改成功，请重新登录！");
                        $("#editUser").modal("hide");
                        logout();
                    },
                    error: function () {
                        alert("修改失败");
                    }
                })
            }
        }
    });

    function logout() {
        $.ajax({
            type: "get",
            url: "/logout",
            dataType: "json",
            success: function (data) {
                localStorage.clear();
                window.location.href = "/pagehome/login.html";
            },
            error: function () {
                alert("退出登录失败");
            }
        })
    }

    $(function () {
        /*
        * 获取localStorage中的用户信息
        * */
        vm.user = JSON.parse(localStorage.getItem("user"));
    })

</script>


</body>
</html>
</html>